package com.richie696.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 全局异常处理器
 */
@ControllerAdvice
public class GlobalExceptionResolver {


    @ExceptionHandler(Exception.class)
    public String handleException(
            Exception exception, HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 异常处理逻辑
        request.setAttribute("msg", exception.getMessage());
        return "error";
    }

}
